Skip to content

Refactor place.cpp Part III #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2020

Conversation

Bill-hbrhbr
Copy link
Contributor

Description

#1529

  • Created placer context for accessing various data structures.
  • Moved timing update related routines to place_timing_update.h/cpp.
  • Moved connection delay related routines to place_delay_model.h/cpp.
  • Added documentation on Override Delay Model.

#1534 (Discussion) #1542 (Merge)

  • Merged t_placer_costs and t_placer_inverse_costs.
  • Use t_annealing_state to reduce function argument list's length.
  • Refactor t_annealing_state update routines.

(This PR)

  • Moved t_placer_statistics to place_util.h/cpp and clean up related routines.
  • Change all pass by pointers to pass by references (only for utility structures in place_utils.h).
  • Wrap timing update related classes into a single object and either
    (1. pass by arguments)
    (2. move it into the placer global context)

Future PR ideas:

  • Move all the bonding box cost (wiring cost) routines into new files.
  • Move all the placement consistency checking routines into new files.
  • Move all the placer status report/logging routines into new files.

Motivation and Context

Refactor place.cpp to modularize it and reduce its length and complexity.

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

… routines to faciliate code modularization. Added documentation and cleaned up the argument list of related routines.
@Bill-hbrhbr Bill-hbrhbr self-assigned this Sep 15, 2020
@probot-autolabeler probot-autolabeler bot added lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool labels Sep 15, 2020
Comment on lines +281 to +312
void t_placer_statistics::reset() {
av_cost = 0.;
av_bb_cost = 0.;
av_timing_cost = 0.;
sum_of_squares = 0.;
success_sum = 0;
success_rate = 0.;
std_dev = 0.;
}

void t_placer_statistics::single_swap_update(const t_placer_costs& costs) {
success_sum++;
av_cost += costs.cost;
av_bb_cost += costs.bb_cost;
av_timing_cost += costs.timing_cost;
sum_of_squares += (costs.cost) * (costs.cost);
}

void t_placer_statistics::calc_iteration_stats(const t_placer_costs& costs, int move_lim) {
if (success_sum == 0) {
av_cost = costs.cost;
av_bb_cost = costs.bb_cost;
av_timing_cost = costs.timing_cost;
} else {
av_cost /= success_sum;
av_bb_cost /= success_sum;
av_timing_cost /= success_sum;
}
success_rate = success_sum / float(move_lim);
std_dev = get_std_dev(success_sum, sum_of_squares, av_cost);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to add function level descriptions to these. Will do it in the future.

@vaughnbetz
Copy link
Contributor

Nice refactoring Bill. Cleaner and much better commented than what was there before. Thanks!

@vaughnbetz vaughnbetz merged commit dac4668 into verilog-to-routing:master Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants